package com.itheima.job.jobTest3;

import java.util.ArrayList;

public class GouWuChe {
    private ArrayList<Goods> goods = new ArrayList<>();

    public GouWuChe(ArrayList<Goods> goods) {
        this.goods = goods;
    }

    public GouWuChe() {
    }

    public void addGoods(Goods goods1){
        goods.add(goods1);
    }

    public void removeGoods(){}

    public void total(){
        double yuanjia=0.0;
        double daze=0.0;
        for (int i = 0; i < goods.size(); i++) {
            Goods goods1 = goods.get(i);
            double price =goods1.getPrice();
            yuanjia += price;
            if (goods1 instanceof EGoods){
                price*=0.88;
            }
            daze+=price;
        }
        System.out.println("------------------");
        System.out.println("原 价为:" + yuanjia + " 元");
        System.out.println("折后价为:" + daze + " 元");

    }

    public void show(){
        for (int i = 0; i < goods.size(); i++) {
            Goods goods1 = goods.get(i);
            System.out.println("加入 "+goods1.getName()+" 商品");
        }
    }
}
